Imports System.Data.SqlClient
Imports System.Configuration
Imports System.XML
Public Class Cls_DCTDevHdlr
    Public Function GettableList(ByVal strConString)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim objCon As New SqlConnection(strConString)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_GetTableCreationList"
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
    Public Function GettableListHO(ByVal strConString)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim objCon As New SqlConnection(strConString)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_GetTableCreationListHO"
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
    Public Function InsertData(ByVal obj As Cls_DCTtableselection, ByVal strConString As String) As Boolean
        Dim arrParams As SqlParameter
        Dim objcmd As New SqlCommand
        Dim objCon As New SqlConnection(strConString)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_Inserttables"
        Dim xmlDoc As XmlDocument = AppHelper.GetXmlDocument(obj)
        arrParams = New SqlParameter("@XmlDoc", SqlDbType.NText)
        arrParams.Value = xmlDoc.InnerXml
        objcmd.Parameters.Add(arrParams)
        objcmd.ExecuteNonQuery()
    End Function
    Public Function GetAlltableList(ByVal strcon As String)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim objCon As New SqlConnection(strcon)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_getalltables"
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
    Public Function GetAllDbNames(ByVal strcon As String)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim objCon As New SqlConnection(strcon)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_getdbnames"
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
    Public Function GetDCTtableList(ByVal strcon As String)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim objCon As New SqlConnection(strcon)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_getDCTtables"
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
    Public Function UpdateDMLData(ByVal obj As Cls_DCTDMLSelection, ByVal strConString As String) As Boolean
        Dim arrParams As SqlParameter
        Dim objcmd As New SqlCommand
        Dim objCon As New SqlConnection(strConString)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_UpdateDMLStatus"
        Dim xmlDoc As XmlDocument = AppHelper.GetXmlDocument(obj)
        arrParams = New SqlParameter("@XmlDoc", SqlDbType.NText)
        arrParams.Value = xmlDoc.InnerXml
        objcmd.Parameters.Add(arrParams)
        objcmd.ExecuteNonQuery()
    End Function
    Public Function InsertImportScripts(ByVal strConString As String) As Boolean
        Dim objcmd As New SqlCommand
        Dim objCon As New SqlConnection(strConString)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_GenerateImportqueries"
        objcmd.ExecuteNonQuery()
    End Function
    Public Function GetImportScripts(ByVal strcon As String)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim objCon As New SqlConnection(strcon)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_getImportScripts"
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
    Public Function GetDCTTableNames(ByVal strcon As String)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim objCon As New SqlConnection(strcon)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_getDCTTableNames"
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
    Public Function GetDCTTableColumns(ByVal tblid As String, ByVal strcon As String)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim arrParams As SqlParameter
        Dim objCon As New SqlConnection(strcon)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_getDCTTableColumnNames"
        arrParams = New SqlParameter("@tblID", SqlDbType.VarChar)
        arrParams.Value = tblid
        objcmd.Parameters.Add(arrParams)
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
    Public Function InsertPKData(ByVal obj As Cls_DCTPKSelection, ByVal strConString As String) As Boolean
        Dim arrParams As SqlParameter
        Dim objcmd As New SqlCommand
        Dim objCon As New SqlConnection(strConString)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_InsertDCTTablePK"
        Dim xmlDoc As XmlDocument = AppHelper.GetXmlDocument(obj)
        arrParams = New SqlParameter("@XmlDoc", SqlDbType.NText)
        arrParams.Value = xmlDoc.InnerXml
        objcmd.Parameters.Add(arrParams)
        objcmd.ExecuteNonQuery()
    End Function
    Public Function InsertdelTableData(ByVal obj As Cls_DCTDelTableSelection, ByVal strConString As String) As Boolean
        Dim arrParams As SqlParameter
        Dim objcmd As New SqlCommand
        Dim objCon As New SqlConnection(strConString)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_InsertDeltables"
        Dim xmlDoc As XmlDocument = AppHelper.GetXmlDocument(obj)
        arrParams = New SqlParameter("@XmlDoc", SqlDbType.NText)
        arrParams.Value = xmlDoc.InnerXml
        objcmd.Parameters.Add(arrParams)
        objcmd.ExecuteNonQuery()
    End Function
    Public Function GetLivetableList(ByVal strConString)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim objCon As New SqlConnection(strConString)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_GetDelTableCreationList"
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
    Public Function GetTriggerScriptList(ByVal strConString)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim objCon As New SqlConnection(strConString)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_CreateTrgrScript"
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
    Public Function InsertStagingScripts(ByVal strConString As String) As Boolean
        Dim objcmd As New SqlCommand
        Dim objCon As New SqlConnection(strConString)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_GenerateStagingScripts"
        objcmd.ExecuteNonQuery()
    End Function
    Public Function GetStagingScripts(ByVal strcon As String)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim objCon As New SqlConnection(strcon)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_getStagingScripts"
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
    Public Function InsertPreImpScripts(ByVal strConString As String) As Boolean
        Dim objcmd As New SqlCommand
        Dim objCon As New SqlConnection(strConString)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_GeneratePreImpScripts"
        objcmd.ExecuteNonQuery()
    End Function
    Public Function GetPreImpScripts(ByVal strcon As String)
        Dim objcmd As New SqlCommand
        Dim dsObj As New DataSet
        Dim objCon As New SqlConnection(strcon)
        objCon.Open()
        objcmd.Connection = objCon
        objcmd.CommandType = CommandType.StoredProcedure
        objcmd.CommandText = "sp_getPreImpScripts"
        Dim da As New SqlDataAdapter
        da = New SqlDataAdapter(objcmd)
        da.Fill(dsObj)
        Return dsObj
    End Function
End Class
